'use strict';
module.exports = {
	/**
	 * XXXnameXXX
	 * @url client/fenximy/kh/getmyshuju 前端调用的url参数地址
	 * data 请求参数
	 * @param {String} params1  参数1
	 */
	main: async (event) => {
		let {
			data = {}, userInfo, util, filterResponse, originalParam
		} = event;
		let {
			customUtil,
			uniID,
			config,
			pubFun,
			vk,
			db,
			_
		} = util;
		let {
			uid
		} = data;
		let res = {
			code: 0,
			msg: ""
		};
		// 业务逻辑开始-----------------------------------------------------------
		let {
			todayStart,
			todayEnd
		} = vk.pubfn.getCommonTime(new Date());
		let sevendayStart = vk.pubfn.getOffsetTime(todayStart, {
			day: 7,
			mode: "before", // after 之后 before 之前
		});
		console.log('sevendayStart ', sevendayStart);



		//获取总收益：
		res.sum = await vk.baseDao.sum({
			dbName: "a_recharge", // 表名
			fieldName: "shifu_amount", // 需要求和的字段名
			whereJson: { // 条件
				pay_status: 1,
				invite_code: userInfo.my_invite_code || uid
			}
		});

		//计算冻结中的金额
		res.freezeMoney = await vk.baseDao.sum({
			dbName: "a_tixian", // 表名
			fieldName: "money", // 需要求和的字段名
			whereJson: { // 条件
				user_id: uid,
				status: 0
			}
		});
		console.log("freezeMoney=", res.freezeMoney);

		//查询佣金比例
		res.userInfo = userInfo;

		// commission_rate

		// 业务逻辑结束-----------------------------------------------------------
		return res;
	}
}
